#include "ClipContextData.h"

#include "../IdRootMenu.h"
#include "mcore/tools/setting/KeToolSettings.h"


namespace kepen {
namespace core {
ClipContextData::ClipContextData() :
    nTypeClip(ClipGeometry_Inter),
    nEditTool(MenuId_None),
    nDrawTool(MenuId_None),
    nAffineTool(MenuId_None),
    nEditTool_last(EditTool_Vector),
    nDrawTool_last(IdentifyPick_ByRect),
    nAffineTool_last(EditTool_Pan),
    ewPtr(NULL)
{
    // DrawTool_RectShape
}



bool ClipContextData::isCheckedBy(int id)const
{
    bool  _isChecked = false;
    int val;
    if(ClipBrushType_Combox==id){
        val = this->nDrawTool;
        _isChecked = false ==(MenuId_None == val);
    }else if( AffineTool_Combox==id )
    {
        val = this->nAffineTool;

        _isChecked = false ==(MenuId_None == val);
    }else if( EditTool_Combox==id){
         val = this->nEditTool;
        _isChecked = false ==(MenuId_None == val);
    }else if(Option_VisibleVertexIndex ==id)
    {
        KeToolSettings *keSettingRR2 = ewPtr->getMapToolSettings();

        _isChecked = keSettingRR2->m_visibleVertexIndex;
    }
    return _isChecked;
}

bool ClipContextData::isEnableBy(int id)const
{
    return true;
}

int ClipContextData::getComboBoxDisplay(int id)const
{
    if(ClipBrushType_Combox ==id){
        return nDrawTool_last;
    }else if(EditTool_Combox ==id){
        return nEditTool_last;
    }else if(AffineTool_Combox ==id){
        return nAffineTool_last;
    }
    return MenuId_None;
}

int ClipContextData::getTypeId4Clip(int id) const
{
    if(ClipGeometry_Radio == id)
        return nTypeClip;
    return MenuId_None;
}

void ClipContextData::convertTypeClip()
{
    if(ClipGeometry_Inter == nTypeClip)
        nTypeClip = ClipGeometry_Remove;
    else
        nTypeClip = ClipGeometry_Inter;
}

void ClipContextData::setEditTool(int id)
{
    nEditTool = id;
    nDrawTool = MenuId_None;
    nAffineTool = MenuId_None;

    if(false == (MenuId_None == id))
    {
        nEditTool_last = id;
    }
}

void ClipContextData::setAffineTool(int id)
{
    nEditTool = MenuId_None;
    nDrawTool = MenuId_None;
    nAffineTool = id;

    if(false == (MenuId_None == id))
    {
        nAffineTool_last = id;
    }
}

void ClipContextData::setDrawTool(int id)
{
    nEditTool = MenuId_None;
    nDrawTool = id;
    nAffineTool = MenuId_None;

    if(false == (MenuId_None == id))
    {
        nDrawTool_last = id;
    }
}


}
}
